package com.haidechizi.leetcode;

import java.util.Stack;

/**
 * @author: wangdejun
 * @create: 2020-04-02 11:34
 **/
public class _9_用两个栈实现队列 {

    Stack<Integer> putStack = new Stack<>();

    Stack<Integer> getStack = new Stack<>();

    public void appendTail(int value) {
        putStack.push(value);
    }

    public int deleteHead() {
        if(getStack.isEmpty()) {
            while (!putStack.isEmpty()) {
                getStack.push(putStack.pop());
            }
        }
        if (getStack.isEmpty()) {
            return -1;
        }

        return getStack.pop();
    }
}
